﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace University.Workshop.DataAccess
{
    public static class PaymentDataAccess
    {
        public static DataTable LoadPatientPayment(string patient)
        {
            string stringConnection = "SELECT * from Payment where CiPatient='"+patient+"'";
            using (DBConnection connection = new DBConnection()) 
            {
                return connection.ConsultationSelectDataTable(stringConnection);
            }
        }

        public static bool InsertPayment(Model.Payment payment)
        {
            if (payment != null)
            {
                string stringConnection = "insert into Payment (CiPatient,CiUser,DatePayment,Amount,Balance,TotalPayment,Description) values('" + payment.CIPatient + "','" + 4494524 + "','" + payment.DatePayment + "'," + payment.Amount + "," + payment.Balance + "," + payment.TotalPayment + ",'" + payment.Description + "') ";
                
                return ExecuteConsult(stringConnection);
            }
            else
            {
                return false;
            }
        }
        private static bool ExecuteConsult(string stringConnection)
        {
            using (DBConnection connection = new DBConnection())
            {
                if (connection.CommandExecuteConsult(stringConnection))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
    }
}
